package com.smart.terminal.exec;

import com.jcraft.jsch.ChannelExec;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

/**
 * exec - 连接池
 *
 * @author wf
 * @version 1.0.0
 * @since 2022/11/10
 */
public class ExecGenericObjectPool {

    private final GenericObjectPool<ChannelExec> genericObjectPool;

    public ExecGenericObjectPool(ExecFactory execFactory, GenericObjectPoolConfig<ChannelExec> poolConfig) {
        this.genericObjectPool = new GenericObjectPool<>(execFactory, poolConfig);
    }

    public ChannelExec borrowObject() throws Exception {
        return genericObjectPool.borrowObject();
    }

    public void returnObject(ChannelExec obj) {
        genericObjectPool.returnObject(obj);
    }
}


